﻿#include "ssRect3.h"


namespace StarSeeker
{

ssRect3::ssRect3(void)
{
	Zero();
}

void ssRect3::InitByMinAndSize(ssfloat x, ssfloat y, ssfloat z, ssfloat widthX, ssfloat widthY, ssfloat widthZ)
{
	m_x = x;
	m_y = y;
	m_y = z;
	m_widthX = widthX;
	m_widthY = widthY;
	m_widthZ = widthZ;
}

void ssRect3::InitByCenterAndSize(ssfloat x, ssfloat y, ssfloat z, ssfloat widthX, ssfloat widthY, ssfloat widthZ)
{
	m_x = x- widthX * 0.5f;
	m_y = y - widthY * 0.5f;
	m_y = z - widthZ * 0.5f;
	m_widthX = widthX;
	m_widthY = widthY;
	m_widthZ = widthZ;
}

void ssRect3::InitByMinAndMax(ssfloat minx, ssfloat miny, ssfloat minz, ssfloat maxx, ssfloat maxy, ssfloat maxz)
{
	m_x = minx;
	m_y = miny;
	m_z = minz;
	m_widthX = maxx - minx;
	m_widthY = maxy - miny;
	m_widthZ = maxz - minz;
}

void ssRect3::Zero()
{
	m_x = m_y = m_z = m_widthX = m_widthY = m_widthZ = 0.0f;
}

StarSeeker::ssfloat ssRect3::MaxY() const
{
	return m_y + m_widthY;
}

ssfloat ssRect3::MaxX() const
{
	return m_x + m_widthX;
}

StarSeeker::ssfloat ssRect3::MaxZ() const
{
	return m_z + m_widthZ;
}

ssfloat ssRect3::MinY() const
{
	return m_y;
}

ssfloat ssRect3::MinX() const
{
	return m_x;
}

StarSeeker::ssfloat ssRect3::MinZ() const
{
	return m_z;
}

ssVector3 ssRect3::Max() const
{
	ssVector3 ret(m_x + m_widthX, m_y + m_widthY, m_z + m_widthZ);
	return ret;
}

ssVector3 ssRect3::Min() const
{
	ssVector3 ret(m_x, m_y, m_z);
	return ret;
}

ssVector3 ssRect3::Center() const
{
	ssVector3 ret(m_x+m_widthX*0.5f, m_y+m_widthY*0.5f, m_z+m_widthZ*0.5f);
	return ret;
}

}
